package com.qf2210.group.three.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.List;

/**
 * Study on the 01
 *
 * @Author: liqing
 * @Date: 2022/12/01/23:26
 * @Description:
 */
@NoArgsConstructor
@ToString
public class Page<T> {
    /**
     * 页码
     */
    private int pageNum;
    /**
     * 总页数
     */
    private int allPages;
    /**
     * 总记录数
     */
    private int count;
    /**
     * 前一页页码
     */
    private Page<T> prePage;
    /**
     * 后一页页码
     */
    private Page<T> nextPage;
    /**
     * 每页数据
     */
    private List<T> list;
    /**
     * 页面大小
     */
    private int pageSize;

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        if (pageNum <= 1) {
            this.pageNum = 1;
        } else {
            this.pageNum = pageNum;
        }
    }

    public int getAllPages() {
        return allPages;
    }

    public void setAllPages(int allPages) {
        this.allPages = allPages;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Page<T> getPrePage() {
        return prePage;
    }

    public void setPrePage(Page<T> prePage) {
        this.prePage = prePage;
    }

    public Page<T> getNextPage() {
        return nextPage;
    }

    public void setNextPage(Page<T> nextPage) {
        this.nextPage = nextPage;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        if (pageSize <= 0) {
            this.pageSize = 5;
        } else {
            this.pageSize = pageSize;
        }
    }

    public Page(int pageNum, int allPages, int count, Page<T> prePage, Page<T> nextPage, List<T> list, int pageSize) {
        if (pageNum <= 1) {
            this.pageNum = 1;
        } else {
            this.pageNum = pageNum;
        }
        this.allPages = allPages;
        this.count = count;
        this.prePage = prePage;
        this.nextPage = nextPage;
        this.list = list;
        if (pageSize <= 0) {
            this.pageSize = 5;
        } else {
            this.pageSize = pageSize;
        }
    }
}